package com.budwk.app.sqfw.services.impl;

import com.budwk.starter.database.service.BaseServiceImpl;
import com.budwk.app.sqfw.models.Sqfw_form_summary_pdf;
import com.budwk.app.sqfw.services.SqfwFormSummaryPdfService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.IocBean;

import java.util.List;

@IocBean(args = {"refer:dao"})
public class SqfwFormSummaryPdfServiceImpl extends BaseServiceImpl<Sqfw_form_summary_pdf> implements SqfwFormSummaryPdfService {
    public SqfwFormSummaryPdfServiceImpl(Dao dao) {
        super(dao);
    }

    @Override
    public Sqfw_form_summary_pdf findBySummaryIdAndIndex(String summaryId, Integer index) {
        Cnd cnd = Cnd.NEW();
        SqlExpressionGroup where = cnd.where();
        where.andEquals(Sqfw_form_summary_pdf::getSummaryId, summaryId).andEquals(Sqfw_form_summary_pdf::getIndex, index);
        return this.fetch(cnd);
    }

    @Override
    public List<Sqfw_form_summary_pdf> findBySummaryIdsAndIndex(List<String> summaryIds, Integer index) {
        Cnd cnd = Cnd.NEW();
        SqlExpressionGroup where = cnd.where();
        where.andIn(Sqfw_form_summary_pdf::getSummaryId, summaryIds.toArray(new String[0]))
                .andEquals(Sqfw_form_summary_pdf::getIndex, index);
        return this.query(cnd);
    }
}
